/*
 * Project: BooEditor
 * Author:  Johannes Kuhaupt
 * Last Change:
 *    by:   $Author: $
 *    date: $Date:   $
 * Copyright (c): Johannes Kuhaupt
 * Licence: Creative Commons CC BY-NC-SA 3.0
 */
package start;

import control.GuiManager;
import control.SettingsManager;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author Johannes Kuhaupt
 */
public class HtmlEditor {
    
    
  
    /**
     * @param args the command line arguments
     */
   public static void main(String[] muj) {         
       
       java.awt.EventQueue.invokeLater(new Runnable() {

           @Override
            public void run() {
               boolean linuxGtk = false;
              
                   
                   try {
                       UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
                       linuxGtk = true;
                       
                } catch (Exception e) {
                    System.err.println("Error Setting LookAndFeel. No problem if you use windows");
                    
                }
                   
                   if(!linuxGtk){
                    try {
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    } catch (ClassNotFoundException ex) {
                        Logger.getLogger(HtmlEditor.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (InstantiationException ex) {
                        Logger.getLogger(HtmlEditor.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (IllegalAccessException ex) {
                        Logger.getLogger(HtmlEditor.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (UnsupportedLookAndFeelException ex) {
                        Logger.getLogger(HtmlEditor.class.getName()).log(Level.SEVERE, null, ex);
                    }
                   }
                   
                   
               SettingsManager.createStandardSettings();
               GuiManager gui = GuiManager.getInstance();
               gui.startGui(true);
               
                
                //Checken ob Datei da ist und nicht schreibgeschützt
                //Ja: auf inhaltliche Korrektheit testen + Laden
                //Nein: Datei anlegen + laden, ggf. Error raushauen
                
                /**Config-Datei vorhanden und schreibar/lesbar
                if(SettingsManager.isConfigFileUsable()){
                    //Config-Datei hat korrekten Inhalt (Optionen stimmen, Werte sind egal)
                    if(SettingsManager.hasRightConfigFileContent()){
                        //alles super -> Einlesen
                        SettingsManager.readConfig();
                        //for debug: SettingsManager.printSettings();
                        GuiManager gui = GuiManager.getInstance();
                        gui.startGui(false);                
                        
                    }
                    else{
                        GuiManager gui = GuiManager.getInstance();
                        gui.showErrorMessage(GuiManager.getLangBundle().getString("MsgErrorCorruptConfig"));
                        SettingsManager.createStandardSettings();
                        //SettingsManager.writeSettingsToFile();
                        //SettingsManager.lockOptionsFile();
                        gui.startGui(true);
                    }
                }
                else{
                    
                    if(SettingsManager.newConfigFileCreatable()){
                        GuiManager gui = GuiManager.getInstance();
                        SettingsManager.createStandardSettings();
                        SettingsManager.writeSettingsToFile();
                        gui.showMessage(GuiManager.getLangBundle().getString("MsgErrorNoConfigFile"));
                        gui.startGui(true);
                        
                    }
                    else{
                        GuiManager gui = GuiManager.getInstance();
                        gui.showErrorMessage(GuiManager.getLangBundle().getString("MsgErrorNoConfigNoStart"));
                        
                    }
                    
                }
                
                
              */  
                
            }
        });
        
                
                
    }
    
        
}
